package main

import "fmt"

// 字符串和allowed拥有相同的字符，则为一致字符串

func countConsistentStrings(allowed string, words []string) int {
	mAllow := make(map[byte]struct{})
	for i := 0; i < len(allowed); i++ {
		mAllow[allowed[i]] = struct{}{}
	}
	var res int
	for _, word := range words {
		var i int
		for i = 0; i < len(word); i++ {
			if _, has := mAllow[word[i]]; !has {
				break
			}
		}
		if i == len(word) {
			res++
		}
	}
	return res
}

func main() {
	var allowed = "ab"
	var words = []string{"ad", "bd", "aaab", "baa", "badab"}
	res := countConsistentStrings(allowed, words)
	fmt.Println(res)
}
